< previous page page_443 next page >

Page 443
Table 22.2 Methods of the Collection Class.
MethodDescription
AddAdds one item to the Collection class. You pass to the Add method an object you want to add. You can optionally pass a Key value to assign to the Key property of this element that uniquely identifies this object. You can also pass a parameter specifying which element you want to insert this object before or after.
ItemWhen you call the Item method, you pass in a Key value or an index number of the element you want to return an object pointer for. If the Item method detects a numeric value passed to it, it searches for the element using the Index number. If the item method detects a string value passed to it, it searches for the element using the Key value.
RemoveThe Remove method eliminates an element from the collection. You need to pass to the Remove method the Key or the index number of the element to remove.

Using the Collection Class
Lets now look at an example of using the Collection class in a real-world situation. Remember the Employee class you created in an earlier chapter? Youll now create an example that adds one or many instances of the Employee class to a collection (see Figure 22.2).
Examples Filename: Emp1.frm
8160-0443a.gif
Figure 22.2
The 
Collection ClassExample 1.

 
< previous page page_443 next page >

If you like this book, buy it!